//
//  YZMSavedStock.m
//  YZMicroStock
//
//  Created by wangminhong on 16/4/11.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZMSavedStock.h"

@implementation YZMSavedStock

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self)
    {
        self.name = [aDecoder decodeObjectForKey: @"stockName"];
        self.code = [aDecoder decodeObjectForKey: @"stockCode"];
        self.price = [aDecoder decodeDoubleForKey: @"price"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject: self.name forKey: @"stockName"];
    [aCoder encodeObject: self.code forKey: @"stockCode"];
    [aCoder encodeFloat: self.price forKey: @"price"];
}


- (BOOL)isEqual:(YZMSavedStock *)object{
    
    if ([object class] == [self class]) {
        return [self.code isEqualToString:object.code];
    }
    return NO;
}

- (NSUInteger)hash {
    
    return [self.code hash];
}


- (NSString *)pureCodeStr
{
    if (self.code.length > 2) {
        return [self.code substringFromIndex: 2];
    }
    return nil;
}


@end
